from multiprocessing import Process

# 多个进程之间（并行），数据不可共享
a = 100

def add():
    print('加的进程开始执行')
    global a
    a += 30
    print('a= ', a)
    print('加的进程执行结束')

def sub():
    print('减的进程开始执行')
    global a
    a -= 50
    print('a= ', a)
    print('减的进程执行结束')

if __name__ == '__main__':
    print('父进程开始执行')
    print('a= ', a)
    p1 = Process(target=add)
    p2 = Process(target=sub)

    p1.start()
    p2.start()

    p1.join()
    p2.join()

    print('父进程执行结束')
    print('a= ', a)